package com.ruoyi.web.controller.mes;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.ruoyi.web.domain.MesMakeversionDetail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.MesMakeVersion;
import com.ruoyi.web.service.IMesMakeVersionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 做版管理Controller
 * 
 * @author wxt
 * @date 2024-02-02
 */
@Api("做版管理")
@RestController
@RequestMapping("/mes/version")
public class MesMakeVersionController extends BaseController
{
    @Autowired
    private IMesMakeVersionService mesMakeVersionService;

    /**
     * 查询做版管理列表
     */
    @ApiOperation("查询做版管理列表")
    @GetMapping("/list")
    public TableDataInfo list(MesMakeVersion mesMakeVersion)
    {
        startPage();
        List<MesMakeVersion> list = mesMakeVersionService.selectMesMakeVersionList(mesMakeVersion);
        return getDataTable(list);
    }

    /**
     * 导出做版管理列表
     */
    @ApiOperation("导出做版管理列表")
    @Log(title = "做版管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesMakeVersion mesMakeVersion)
    {
        List<MesMakeVersion> list = mesMakeVersionService.selectMesMakeVersionList(mesMakeVersion);
        ExcelUtil<MesMakeVersion> util = new ExcelUtil<MesMakeVersion>(MesMakeVersion.class);
        util.exportExcel(response, list, "做版管理数据");
    }

    /**
     * 获取做版管理详细信息
     */
    @ApiOperation("获取做版管理详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesMakeVersionService.selectMesMakeVersionById(id));
    }

    @ApiOperation("做版明细查询")
    @PostMapping(value = "/DetailList")
    public TableDataInfo getDetailList(@RequestBody Map<String,String> params)
    {
        startPage(params);
       // PageHelper.startPage(Integer.parseInt(params.get("pageNum")), Integer.parseInt(params.get("pageSize")));
        MesMakeversionDetail detail=new MesMakeversionDetail();
        detail.setWhere(params);
        List<MesMakeversionDetail> list = mesMakeVersionService.getDetailList(detail);
        return getDataTable(list);
    }

    /**
     * 新增做版管理
     */
    @ApiOperation("新增做版管理")
    @Log(title = "做版管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesMakeVersion mesMakeVersion)
    {
        return toAjax(mesMakeVersionService.insertMesMakeVersion(mesMakeVersion));
    }

    /**
     * 修改做版管理
     */
    @ApiOperation("修改做版管理")
    @Log(title = "做版管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesMakeVersion mesMakeVersion)
    {
        return toAjax(mesMakeVersionService.updateMesMakeVersion(mesMakeVersion));
    }

    /**
     * 删除做版管理
     */
    @ApiOperation("删除做版管理")
    @Log(title = "做版管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesMakeVersionService.deleteMesMakeVersionByIds(ids));
    }
}
